import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { DroneListApi } from '#/api/detection/dronelist';

import { getRangePickerDefaultProps } from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'droneId',
      label: '无人机id（侦测设备生成）',
      component: 'Input',
      componentProps: {
        placeholder: '请输入无人机id（侦测设备生成）',
      },
    },
    {
      fieldName: 'snCode',
      label: '无人机序列号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入无人机序列号',
      },
    },
    {
      fieldName: 'droneHeight',
      label: '无人机高度',
      component: 'Input',
      componentProps: {
        placeholder: '请输入无人机高度',
      },
    },
    {
      fieldName: 'model',
      label: '型号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入型号',
      },
    },
    {
      fieldName: 'firstDetectedAt',
      label: '首次发现日期',
      component: 'Input',
      componentProps: {
        placeholder: '请输入首次发现日期',
      },
    },
    {
      fieldName: 'droneGpsLat',
      label: '无人机纬度',
      component: 'Input',
      componentProps: {
        placeholder: '请输入无人机纬度',
      },
    },
    {
      fieldName: 'droneGpsLng',
      label: '无人机经度',
      component: 'Input',
      componentProps: {
        placeholder: '请输入无人机经度',
      },
    },
    {
      fieldName: 'sensorId',
      label: '雷达id',
      component: 'Input',
      componentProps: {
        placeholder: '请输入雷达id',
      },
    },
    {
      fieldName: 'droneAzimuth',
      label: '无人机方位角',
      component: 'Input',
      componentProps: {
        placeholder: '请输入无人机方位角',
      },
    },
    {
      fieldName: 'droneDistance',
      label: '无人机距离',
      component: 'Input',
      componentProps: {
        placeholder: '请输入无人机距离',
      },
    },
    {
      fieldName: 'rcGpsLat',
      label: '遥控器纬度',
      component: 'Input',
      componentProps: {
        placeholder: '请输入遥控器纬度',
      },
    },
    {
      fieldName: 'rcGpsLng',
      label: '遥控器经度',
      component: 'Input',
      componentProps: {
        placeholder: '请输入遥控器经度',
      },
    },
    {
      fieldName: 'rcAzimuth',
      label: '遥控器方位角',
      component: 'Input',
      componentProps: {
        placeholder: '请输入遥控器方位角',
      },
    },
    {
      fieldName: 'rcDistance',
      label: '遥控器距离',
      component: 'Input',
      componentProps: {
        placeholder: '请输入遥控器距离',
      },
    },
    {
      fieldName: 'requestStatus',
      label: '请求状态',
      component: 'RadioGroup',
      componentProps: {
        options: [],
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'errorMessage',
      label: '错误信息',
      component: 'Input',
      componentProps: {
        placeholder: '请输入错误信息',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'snCode',
      label: '无人机序列号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入无人机序列号',
      },
    },
    {
      fieldName: 'droneHeight',
      label: '无人机高度',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入无人机高度',
      },
    },
    {
      fieldName: 'model',
      label: '型号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入型号',
      },
    },
    {
      fieldName: 'droneGpsLat',
      label: '无人机纬度',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入无人机纬度',
      },
    },
    {
      fieldName: 'droneGpsLng',
      label: '无人机经度',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入无人机经度',
      },
    },
    {
      fieldName: 'sensorId',
      label: '雷达id',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入雷达id',
      },
    },
    {
      fieldName: 'droneDistance',
      label: '无人机距离',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入无人机距离',
      },
    },
    {
      fieldName: 'rcGpsLat',
      label: '遥控器纬度',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入遥控器纬度',
      },
    },
    {
      fieldName: 'rcGpsLng',
      label: '遥控器经度',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入遥控器经度',
      },
    },
    {
      fieldName: 'rcAzimuth',
      label: '遥控器方位角',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入遥控器方位角',
      },
    },
    {
      fieldName: 'rcDistance',
      label: '遥控器距离',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入遥控器距离',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建日期',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<DroneListApi.DroneList>['columns'] {
  return [
    { type: 'checkbox', width: 40 },
    // {
    //   field: 'id',
    //   title: '编号',
    //   minWidth: 120,
    // },
    {
      field: 'snCode',
      title: '无人机序列号',
      minWidth: 120,
    },
    {
      field: 'droneHeight',
      title: '无人机高度',
      minWidth: 120,
    },
    {
      field: 'model',
      title: '型号',
      minWidth: 120,
    },
    {
      field: 'firstDetectedAt',
      title: '首次发现日期',
      minWidth: 120,
    },
    {
      field: 'droneGpsLat',
      title: '无人机纬度',
      minWidth: 120,
    },
    {
      field: 'droneGpsLng',
      title: '无人机经度',
      minWidth: 120,
    },
    {
      field: 'sensorId',
      title: '雷达id',
      minWidth: 120,
    },
    {
      field: 'droneAzimuth',
      title: '无人机方位角',
      minWidth: 120,
    },
    {
      field: 'droneDistance',
      title: '无人机距离',
      minWidth: 120,
    },
    {
      field: 'rcGpsLat',
      title: '遥控器纬度',
      minWidth: 120,
    },
    {
      field: 'rcGpsLng',
      title: '遥控器经度',
      minWidth: 120,
    },
    {
      field: 'rcAzimuth',
      title: '遥控器方位角',
      minWidth: 120,
    },
    {
      field: 'rcDistance',
      title: '遥控器距离',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建日期',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    // {
    //   field: 'requestStatus',
    //   title: '请求状态',
    //   minWidth: 120,
    // },
    // {
    //   field: 'errorMessage',
    //   title: '错误信息',
    //   minWidth: 120,
    // },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
